# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=golang-gopkg-alecthomas-kingpin.v2
pkgver=2.2.6
pkgrel=4
pkgdesc='A Go (golang) command line and flag parser'
arch=('any')
url="https://gopkg.in/alecthomas/kingpin.v2"
license=('MIT')
depends=('go' 'golang-github-alecthomas-template' 'golang-github-alecthomas-units')
checkdepends=('golang-github-stretchr-testify')
source=("$pkgname-$pkgver.tar.gz::https://github.com/alecthomas/kingpin/archive/v$pkgver.tar.gz")
sha512sums=('09c6bb5782639efc7068ed7606fe22c463b2397dc95a89c27ba567a58da10660bfea60d7836b63dcedf7db702f79fe7247575c33a503990f5ba6ca92e29b06b3')

check() {
  export GO111MODULE=off
  export GOPATH="$srcdir/build:/usr/share/gocode"
  mkdir -p "$srcdir"/build/src/gopkg.in/alecthomas
  cp -a "$srcdir"/kingpin-$pkgver "$srcdir"/build/src/gopkg.in/alecthomas/kingpin.v2
  cd "$srcdir"/build/src/gopkg.in/alecthomas/kingpin.v2
  go test -v $(go list ./...)
}

package() {
  mkdir -p "$pkgdir"/usr/share/gocode/src/gopkg.in/alecthomas
  cp -a "$srcdir"/kingpin-$pkgver "$pkgdir"/usr/share/gocode/src/gopkg.in/alecthomas/kingpin.v2

  install -Dm644 kingpin-$pkgver/COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
}
